#ifndef _SPRITE_H_
#define _SPRITE_H_

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "video.h"


/** @defgroup sprite Sprite
 * @{
 *
 * Sprite related functions.
 */

typedef struct {
	int x;				 ///< Current x sprite position.
	int y;				 ///< Current y sprite position.
	int width;			 ///< Sprite x dimension.
	int height;			 ///< Sprite y dimension.
	int xspeed;			 ///< Sprite current speed in x direction.
	int yspeed;			 ///< Sprite current speed in y direction.
	char *map;       	        ///< The sprite pixmap.
	char *bgmap;		 ///< The sprite background map.
} Sprite;


char* read_xpm(char *map[], int *width, int *height);


char* read_xpm_file(char* filename, int *wd, int *ht);

Sprite* create_sprite(char *pic[]);

Sprite* create_unbuffered_sprite(char *pic[]);

Sprite* create_unbuffered_sprite_from_file(char* filename);

void draw_sprite(Sprite *sprt, char *base);

void draw_sprite_at(Sprite* sprt, int x, int y, char *base);

void delete_sprite(Sprite *sprt, char *base);

void destroy_sprite(Sprite *sprt);

void draw_sprite_scaled(Sprite *sprt, char *base, int width, int height);

void delete_sprite_scaled(Sprite *sprt, char *base, int width, int height);

void move_sprite(Sprite *sprt, int x, int y, char *base);

void flip_buffer(char* dest, char* src);

void flip_buffer_partial(char* dest, char* src, int xi, int yi, int width, int height);

#endif
